#include<iostream>
#include<vector>

using namespace std;
void dfs(vector<vector<char>> &grid, int y, int x, int row, int col) {
    if (x < 0 || x >= col || y < 0 || y >= row || grid[y][x] == '0') {
        return;
    }
    grid[y][x] = 0;
    dfs(grid, y - 1, x, row, col);
    dfs(grid, y + 1, x, row, col);
    dfs(grid, y, x - 1, row, col);
    dfs(grid, y, x + 1, row, col);
}
int numIslands(vector<vector<char>>& grid) {
    if (grid.size == 0 && grid[0].size() == 0 && grid[0][0] == '1') {
        return 1;
    }
    if (grid.size == 0 && grid[0].size() == 0 && grid[0][0] == '0') {
        return 0;
    }
    int cnt(0);
    int row = grid.size();
    int col = grid[0].size();
    for (int y = 0; y < row; y++) {
        for (int x = 0; x < col; x++) {
            cnt += grid[y][x] - '0';
            dfs(grid, y, x, row, col);
        }
    }
    return cnt;
}

int main() {

}